﻿<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Login.aspx.cs" Inherits="Testify.Account.Login" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:HiddenField ID="hidUserID" runat="server" />
    <asp:SqlDataSource ID="sqlLogin" runat="server"
        ConnectionString="<%$ ConnectionStrings:Singularity %>"
	    ProviderName="<%$ ConnectionStrings:Singularity.ProviderName %>" 
        SelectCommandType="StoredProcedure" 
        SelectCommand="execute singularity.users.credentialsmatch(p_UserName, p_UserPassword, p_UserID, p_UserTypeID)">
        <SelectParameters>
            <asp:Parameter Name="p_Username" />
            <asp:Parameter Name="p_UserPassword" />
            <asp:ControlParameter ControlID="hidUserID" Direction="Output" Name="p_UserID" 
                PropertyName="Value" />
            <asp:ControlParameter ControlID="hidUserTypeID" Direction="Output" 
                Name="p_UserTypeID" PropertyName="Value" />
            <asp:Parameter Direction="ReturnValue" Name="returned" Type="Boolean" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ProviderName="Oracle.DataAccess.Client"></asp:SqlDataSource>
    <asp:HiddenField ID="hidUserTypeID" runat="server" />

    <p style="display:none;">
        Please enter your username and password.
        <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
    </p>
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false"
    RenderOuterTable="false" DestinationPageUrl="~/Default.aspx"  PasswordRequiredErrorMessage="Password Required"
    onauthenticate="LoginUser_Authenticate1">
        <LayoutTemplate>
            <asp:Panel runat="server" ID="failureBox" Visible="false" CssClass="failureNotification">
                <asp:Literal ID="FailureText" runat="server"></asp:Literal>
            </asp:Panel>
            <div class="accountInfo">
               <%-- <fieldset class="login">
                    <legend>Account Information</legend>--%>
                    <h2>
                        Please Sign In
                    </h2>
                    <div class="textbox-space">
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
                             CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </div>
                    <div class="textbox-space">
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                             CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </div>
                    
                <%--</fieldset>--%>
                <p class="submitButton">
                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" onclick="LoginButton_Click" CssClass="Button" />
                </p>
                <br /><br /><br /><br /><br />
                <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
                 ValidationGroup="LoginUserValidationGroup"/>
            </div>
        </LayoutTemplate>
    </asp:Login>    
</asp:Content>
